package com.android.lovely.aav.discount

import com.airbnb.lottie.LottieAnimationView
import com.airbnb.lottie.LottieCompositionFactory
import java.io.File

class LottieFileLoader {

    fun loadAnimFile(lottie: LottieAnimationView, file: File) {
        val fileName = file.name
        if (fileName.endsWith("json")) {
            LottieCompositionFactory.fromJsonInputStream(file.inputStream(), file.name)
                .addListener { result ->
                    result?.let {
                        lottie.setComposition(it)
                        lottie.playAnimation()
                    }
                }
        }
    }
}